--[[ 编码: JX-800-01 名称: 堆垛机任务数量(柱状图) 作者:HAN 日期:2025-1-29 级别: 固定 (说明本段代码在项目中不太会变化) 函数: GenChartJson 功能: 统计作业各种状态的数量(测试一下用) 更改记录: --]] json = require("json") mobox = require("OILua_JavelinExt") m3 = require("oi_base_mobox") function GenChartJson(strLuaDEID) local nRet, strRetInfo --[[ 文字颜色 ]] local strColor = "#fff" --[[ 文字标题 ]] local strTitle = "堆垛机任务数量" --[[ 柱状图柱子名称,对应 series 下name ]] local tabLegendData = {'任务数量'} --[[ Y轴数据 从下向上 ]] local tabYAxis = {'TD1', 'TD2', 'TD3', 'TD4' } --[[ 柱状图数据 对应Y轴数据 ]] local tabSeriesData = {320, 302, 101, 500} -- 做测试 页面动态定时刷新 值动态变化----------------------- local now = os.date("*t") -- 获取当前时间 local hour = now.hour local minute = now.min local second = now.sec -- 将时、分、秒组合成一个整数 local timeAsInteger = hour + second tabSeriesData = {timeAsInteger+320, timeAsInteger+302, timeAsInteger+101, timeAsInteger+500} --------------------------------------------------------------------- local option = { title = { text = strTitle, left = 20, textStyle = { color = strColor }, top = 10 }, grid = { left = '5%', right = '5%', bottom = '5%', top = '20%', containLabel = true }, legend = { data = tabLegendData, textStyle = { color = strColor }, top = 10 }, xAxis = { type = 'value', axisLabel = { textStyle = { color = strColor } }, splitLine = { show = false } }, yAxis = { type = 'category', data = tabYAxis, axisLabel = { textStyle = { color = strColor } } }, series = { name = '任务数量', type = 'bar', stack = 'total', label = { show = true }, data = tabSeriesData } } local action = { { action_type = "chart", value = { graphicType = "echart", title = { text = strTitle, align = "center", color = "#515a6e", font = "微软雅黑", fontSize = 12 }, option = option } } } nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action)) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction) end end